<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:71:"E:\phpstudy_pro\WWW\c\public/../application/after\view\after\create.html";i:1630656807;}*/ ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <input type="hidden" name="__token__" value="<?php echo \think\Request::instance()->token(); ?>"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>登录</title>
    <!--    <link rel="stylesheet" href="/static/admin/css/login.css">-->
    <link rel="stylesheet" href="/static/admin/css/login.css">
    <script src="https://lib.sinaapp.com/js/jquery/2.0.2/jquery-2.0.2.min.js">
    </script>
    <!-- 作者QQ:951252660 -->
</head>
<body>
<div class="login">
    <div class="center">
        <h1>Login</h1>
        <div class="inputLi">
            <strong>账户</strong>
            <input type="text" class="username" placeholder="手机号/邮箱/账号登录..." name="username" id="username" value="">
        </div>
        <div class="inputLi">
            <strong>密码</strong>
            <input type="password" class="password" placeholder="请输入密码" name="password" id="password">
        </div>

        <div class="inputLi">
            <button id="login" onclick="login()">登录</button>
        </div>
    </div>
</div>
</body>
</html>
<script>
    function login() {
        var username = $('.username').val();
        var password = $('.password').val();
        $.ajax({
            "url": "http://www.admin.com/after/after/dologin",
            "type": "POST",
            "data": {
                'username': username,
                'password': password,
                '__token__': "<?php echo \think\Request::instance()->token(); ?>"
            },
            "dataType": 'JSON',
            success: function (e) {
                console.log(e)
                if (e.code == 200) {
                    alert('登陆成功')
                    // 存入token 在本地
                    localStorage.setItem('token', e.data.token)
                    location.href = "http://www.admin.com/after/Show/show?token=" + e.data.token;
                }else {
                    if (e.code!=200){
                        alert('账号或密码有误，请重新输入...')
                    }
                }
            }
        })

    }
</script>
